#include<stdio.h>

#include<iostream>

#include<string.h>

#include<unistd.h>

#include <sys/types.h>

#include <sys/stat.h>

#include <fcntl.h>

using namespace std;

int main()
{
  //chdir("../");

  //FILE *fp = fopen("log.txt", "a");

  //fwrite("hello linux\n", sizeof(char), strlen("hello linux\n"), fp);
  
  //char arr[1024] = {0};

  //fscanf(stdin, "%s", arr);

  //cout << arr << endl;

  //fclose(fp);

  //fp = NULL;

  //umask(0);

//  int fd1 = open("log1.txt", O_WRONLY|O_CREAT|O_TRUNC, 0666);
//  int fd2 = open("log2.txt", O_WRONLY|O_CREAT|O_TRUNC, 0666);
//  int fd3 = open("log3.txt", O_WRONLY|O_CREAT|O_TRUNC, 0666);
//  int fd4 = open("log4.txt", O_WRONLY|O_CREAT|O_TRUNC, 0666);
//  int fd5 = open("log5.txt", O_WRONLY|O_CREAT|O_TRUNC, 0666);
//  
//  cout << fd1 << endl;
//  cout << fd2 << endl;
//  cout << fd3 << endl;
//  cout << fd4 << endl;
//  cout << fd5 << endl;
//
//  close(fd1);
//  close(fd2);
//  close(fd3);
//  close(fd4);
//  close(fd5);
  
  //write(1, "hello linux\n", strlen("hello linux\n"));
  
//  char arr[1024] = {0};
//  read(0, arr, 10);
//  cout << arr << endl;
  
//  close(1);
//  fprintf(stderr, "stderr\n");
//  printf("stdout\n");
//  printf("stdout\n");
//  printf("stdout\n");
//  printf("stdout\n");
  
  //close(1);

  //int fd = open("log.txt", O_WRONLY|O_CREAT|O_APPEND, 0666);
  
  //int fd = open("log.txt", O_RDONLY);

  //fprintf(stderr, "%d\n", fd);

  //dup2(fd, 0);

  //char arr[1024] = {0};

  //fgets(arr, 1024, stdin);

  //cout << arr << endl;

  //write(1, "hello linux\n", strlen("hello linux\n"));
  
  //write(fd, "hello world\n", strlen("hello world\n"));

//  fprintf(stdout, "message1\n");
//  fprintf(stdout, "message2\n");
//  fprintf(stdout, "message3\n");
//  fprintf(stdout, "message4\n");
//  fprintf(stdout, "message5\n");
//  
//  fprintf(stderr, "error1\n");
//  fprintf(stderr, "error2\n");
//  fprintf(stderr, "error3\n");
//  fprintf(stderr, "error4\n");
//  fprintf(stderr, "error5\n");

  printf("printf\n");
  fprintf(stdout, "fprintf\n");
  fwrite("fwrite\n", sizeof(char), strlen("fwrite\n"), stdout);

  write(1, "write\n", strlen("write\n"));
  
  fork();

  //close(1);
  
  return 0;
}
